@extends('layouts.public')

@section('bodyattr')class="gray-bg"@endsection

@section('body')
    <style>
        .mask{
            position: fixed;
            top:0;
            left:0;
            width:100%;
            height:100vh;
            background: rgba(0,0,0,0.75);
            z-index:1300;
            display: none;
        }
        .content{
            width:250px;
            height:130px;
            background: #fff;
            padding:20px;
            position:absolute;
            top:50%;
            left:50%;
            transform: translate(-50%,-50%);
            z-index:1301;
            border-radius: 5px;
        }
        .item{
            margin: 10px 0;
        }
    </style>
    <div class="wrapper wrapper-content">
        <div class="row m-b">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="{{route('admin.share.shares')}}">分享列表</a></li>
                        <li><a href="{{route('admin.share.shares.add')}}">新增</a></li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <form role="form" class="form-inline" method="get">
                            <div class="form-group">
                                <label class="sr-only">分享搜索</label>
                                <input type="text" name="title" placeholder="请输入分享标题" class="form-control" value="{{request('title')}}">
                            </div>
                            &nbsp;&nbsp;
                            <div class="form-group">
                                <input placeholder="请选择创建时间范围" class="form-control" id="created_at" type="text" name="created_at" value="{{request('created_at')}}" style="width: 200px;"
                                       autocomplete="off">
                            </div>
                            <button type="submit" class="btn btn-primary">搜索</button>
                            <button type="button" class="btn btn-white" onclick="location.href='{{route('admin.share.shares')}}'">重置</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
                            <thead>
                            <tr role="row">
                                <th>分享ID</th>
                                <th>标题</th>
                                <th>主图</th>
                                <th>状态</th>
                                <th class="sorting" orderby="created_at">创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            @foreach($shares as $user)
                                <tr class="gradeA">
                                    <td>{{$user['id']}}</td>

                                    <td>{{$user['title']}}</td>
                                    <td><img src="{{get_file_url($user->img)}}" ></td>


                                    <td>@if($user['status']==2)
                                        <span style="color:red">暂停使用</span>
                                        @endif
                                        @if($user['status']==1)
                                            <span style="color:green">使用中</span>
                                        @endif
                                    </td>
                                    <td>{{$user['created_at']}}</td>
                                   
                                    <td>
                                        <a href="{{route('admin.share.shares.edit',[$user->id])}}">编辑</a>|
                                       
                                        @if($user['status']==2)
                                            <a class="ajaxBtn" href="javascript:void(0);" uri="{{route('admin.share.shares.change',[$user->id])}}" msg="使用分享主题后，可在众筹管理选择主题，是否使用该分享？">使用</a>|
                                        @endif

                                        @if($user['status']!=2)
                                            <a class="ajaxBtn" href="javascript:void(0);" uri="{{route('admin.share.shares.change',[$user->id])}}" msg="关闭分享主题后，该主题活动分享将使用默认主题和描述，是否禁用该分享？">禁用</a>|
                                        @endif
                                         <a class="ajaxBtn btn btn-danger" href="javascript:void(0);" uri="{{route('admin.share.shares.delete',[$user->id])}}" msg="删除分享后，该主题活动分享将使用默认主题和描述，请确认是否删除？">删除</a>
                                    </td>
                                </tr>
                            @endforeach
                        </table>
                        <div class="row">
                            <div class="col-sm-12">
                                <div>共 {{ $shares->total() }} 条记录</div>
                                {!! $shares->links() !!}
                            </div>
                        </div>
                    </div>
                </div>
                <div class="mask">
                    <div class="content">
                        <div class="item">
                            <input type="text" placeholder="请输入排名，默认0-100降序" class="form-control" id="rank">
                        </div>
                        <div class="btn btn-default" id="cancel">取消</div>
                        <div class="btn btn-primary" id="saveRank">确定</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script type="text/javascript" src="{{cdn('js/plugins/laydate/laydate.js')}}"></script>
    <script type="text/javascript">
        laydate.render({
            elem: '#created_at',
            range: true,
            max: 0
        });
    </script>
@endsection
